using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using SMB.Data.PulseGS;
//using SMBERP.GS.UserControl;
//using SMB.Utility;
//using SMB.Data.Security;

namespace SMBERP.GS
{
    public partial class fmGSAddConfirm : System.Web.UI.Page
    {
        //DataTable dt;

        //#region init
        //protected override void OnInit(EventArgs e)
        //{
        //    UcDateToolBar1.EventSelectedDate += new ucDateToolBar.SelectedDateEventHandler(UcDateToolBar1_EventSelectedDate);
        //}
        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    dt = (DataTable)Session["fmGSAddConfirm.dt"];
        //    if (!IsPostBack)
        //    {
        //        InitPage();
        //        //InitLocker();
        //        Display();
        //    }
        //}

        //private void InitPage()
        //{
        //    BindddlDiv();
        //    InitLocker();
        //    BindddlRecUser();
        //}
        //private void InitLocker()
        //{
        //    User u = (User)Session["User"];
        //    if (!u.IsTopSuperUser)
        //    {
        //        if (u.IsDivisionSuperUser)
        //        {
        //            ddlDiv.Enabled = false;
        //            ddlDiv.SelectedValue = u.DivisionID;
        //        }
        //    }
            
        //}
        //protected void Display()
        //{
        //    DateTime StartDate = UcDateToolBar1.StartDate;
        //    DateTime EndDate = UcDateToolBar1.EndDate;
        //    dt = GSAdd.getAddPaperForConfirm(txtDocID.Text, ddlRecUser.SelectedValue, ddlDiv.SelectedValue, StartDate, EndDate, false, true);
        //    Session["fmGSAddConfirm.dt"] = dt;
        //    GridView1.SelectedIndex = -1;
        //    GridView1.EditIndex = -1;
        //    BindDataGrid();

        //}
        //protected void Display(string DocID)
        //{
        //    dt = GSAdd.getAddPaperForConfirm(txtDocID.Text, "", "",DateTime.MinValue, DateTime.MinValue, false, true);
        //    Session["fmGSAddConfirm.dt"] = dt;
        //    GridView1.SelectedIndex = -1;
        //    GridView1.EditIndex = -1;
        //    BindDataGrid();   
        //}

        //protected void BindddlDiv()
        //{
        //    DataTable ddldt = GSAdd.getExistRECDivision(false);
        //    ddlDiv.DataTextField = "RecDivFullName";
        //    ddlDiv.DataValueField = "RecDivID";
        //    ddlDiv.DataSource = ddldt;
        //    ddlDiv.DataBind();

        //}

        //protected void BindddlRecUser()
        //{
        //    DataTable ddldt = GSAdd.getExistRecUser(ddlDiv.SelectedValue,false);
        //    ddlRecUser.DataTextField = "RECAcctFullName";
        //    ddlRecUser.DataValueField = "RECAcct";
        //    ddlRecUser.DataSource = ddldt;
        //    ddlRecUser.DataBind();
            
        //}


        //protected void BindDataGrid()
        //{
        //    GridView1.DataSource = dt;
        //    GridView1.DataBind();
        //}

        //#endregion

        //#region event

        //protected void ddlDiv_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    Display();
        //}
        //protected void UcDateToolBar1_EventSelectedDate(DateTime StartDate, DateTime EndDate)
        //{
        //    Display();
        //}

        //protected void btnSchDocID_Click(object sender, EventArgs e)
        //{
        //    Display(txtDocID.Text);
        //}

        //protected void btnConfirm_Click(object sender, EventArgs e)
        //{
        //    string[] ids = getSelectedDocIDs();
        //    if (ids != null)
        //    {
        //        string DocID;
        //        for (int i = 0; i < ids.Length; i++)
        //        {
        //            DocID = ids[i];
        //            GSAdd L = GSManager.getAddPaper(DocID);
        //            try
        //            {
        //                User u = (User)Session["User"];
        //                L.UserAccount = u.UserID;
        //                L.UserName = u.UserName;
        //                GSManager.Confirmed(L);
        //                JScript.Alert("Confirm Sucess!");
        //                Display();
        //            }
        //            catch (Exception ex)
        //            {
        //                JScript.Alert(ex.Message);
        //                break;
        //            }

        //            try
        //            {
        //                //GSManager.SendMailAddConfirm(L);                   
        //            }
        //            catch (System.Exception ex)
        //            {
        //                JScript.Alert(ex.Message);
        //            }
        //        }

        //    }
        //    else
        //    {
        //        JScript.Alert("You don't select any Paper,Please Select!");
        //    }
        //}

        //public string[] getSelectedDocIDs()
        //{
        //    string DocIDs = "";
        //    foreach (GridViewRow gvr in GridView1.Rows)
        //    {
        //        Boolean b = Convert.ToBoolean(((CheckBox)gvr.FindControl("chkboxSelected")).Checked);
                
        //        if (b == true)
        //        {
        //            string DocID = ((Label)gvr.FindControl("lblDocID")).Text;
        //            if (DocIDs == "") { DocIDs = DocID; }
        //            else { DocIDs = DocIDs + "|" + DocID; }
        //        }
        //    }
        //    if (DocIDs == "") { return null; }
        //    else
        //    {
        //        return DocIDs.Split(new char[] { '|' });
        //    }
        //}


        //private void SelectedAll()
        //{
        //    foreach (GridViewRow gvr in GridView1.Rows)
        //    {
        //        ((CheckBox)GridView1.Rows[gvr.RowIndex].FindControl("chkboxSelected")).Checked = true;
        //    }
        //}

        //private void UnSelected()
        //{
        //    foreach (GridViewRow gvr in GridView1.Rows)
        //    {
        //        ((CheckBox)GridView1.Rows[gvr.RowIndex].FindControl("chkboxSelected")).Checked = !((CheckBox)GridView1.Rows[gvr.RowIndex].FindControl("chkboxSelected")).Checked;
        //    }
        //}
        //protected void btnSelectAll_Click(object sender, EventArgs e)
        //{
        //    SelectedAll();
        //}
        //protected void btnUnSelect_Click(object sender, EventArgs e)
        //{
        //    UnSelected();
        //}


        //#endregion --event--

        //#region --GridView--
        //protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        //{
        //    GridView1.EditIndex = -1;
        //    BindDataGrid();
        //}
        //protected void GridView1_RowEditing1(object sender, GridViewEditEventArgs e)
        //{
        //    GridView1.EditIndex = e.NewEditIndex;
        //    BindDataGrid();
        //}

        //protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        //{
        //    GridView1.PageIndex = e.NewPageIndex;
        //    BindDataGrid();
        //}
        //#endregion --GridView--


    }
}
